import 'package:flutter/material.dart';
import 'package:wechat/contacts/contacts_data.dart';

class ContactsItem extends StatelessWidget {
  final ContactsData? item;
  final String? titleName;
  final String? imageName;
  const ContactsItem({super.key, this.item, this.titleName, this.imageName});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 64,
      decoration: const BoxDecoration(
        color: Colors.white,
        border:
            Border(bottom: BorderSide(width: 0.5, color: Color(0xFFdddddd))),
      ),
      child: TextButton(
        onPressed: () {},
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            (imageName != null && imageName != "")
                ? Image.asset(
                    imageName!,
                    width: 36,
                    height: 36,
                  )
                : Image.network(
                    (item?.avatarUrl != null && item?.avatarUrl != "")
                        ? item?.avatarUrl ??
                            "https://p1.itc.cn/mpbp/pro/20211109/63979d780b624e6fb871f08a23f8d431.jpeg"
                        : "https://p1.itc.cn/mpbp/pro/20211109/63979d780b624e6fb871f08a23f8d431.jpeg",
                    width: 36,
                    height: 36,
                  ),
            Container(
              margin: const EdgeInsets.only(left: 10),
              child: Text(
                titleName ?? item?.name ?? "暂无",
                style: const TextStyle(
                  fontSize: 18,
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                ),
                maxLines: 1,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
